#ifndef _CACHE_H
#define _CACHE_H

#include "buffer.h"

extern const size_t CACHE_BUFFER_COUNT;
extern const size_t CACHE_BUFFER_SIZE;

/**
 * wr_index can not beyond array len
 * rd_index can not beyond wr_index
 * tk_index can not beyond wr_index
 * the moving of tk_index change the rd_index
 **/
struct cache{
	int buffer_size;
	int rd_index;
	int wr_index;
	struct buffer *data_arr[16];
	
	struct bufferFactory *bf_hdl;
};
/**
 * if param buffer_size is 0,the function use const var CACHE_BUFFER_SIZE;
 * if param buffer_count is 0,the function use const var CACHE_BUFFER_COUNT;
 **/
extern struct cache* cache_build(size_t buffer_size);
extern int cache_release(struct cache *cc);

#endif
